package com.doctor.base;

import java.io.BufferedReader;

import com.google.gson.Gson;
import com.jfinal.core.Controller;

/**
 * 系统业务控制层基类
 * @author liuhuanchao
 *
 */
public abstract class SysController extends Controller{

	/**
	 * 获取请求参数中的业务Bean
	 * @param objectType
	 * @return
	 */
	protected <T> T getRequestObject(Class<T> objectType) {
		
		StringBuilder json = new StringBuilder();
		
		try{
			
			BufferedReader reader = this.getRequest().getReader();
			String line = null;
			
			while((line = reader.readLine()) != null){
				json.append(line);
			}
			reader.close();
			
			return new Gson().fromJson(json.toString(), objectType);
		}catch(Exception e){
			return null;
		} 
	}
}
